#ifndef UTI_BARSERIES_H_
#define UTI_BARSERIES_H_
#pragma once
#include "sys_config.h"
#include "uti_bar.h"
#include "uti_memman.h"



class BarSeries
{
public:
	BarSeries(BarSerInfo* pbarserinfo);

	~BarSeries();

	void Addbardata(BarData* data);

	//void Addbardata(BarData* data, int f);

	//void SetAccrossday();

	BarData* GetBarData(unsigned int index)
	{
		return (m_pcur - m_index + index);
	};


private:

	//void SetSystime(SYSTEMTIME* ptm, const char* pdate, const char* ptime, int millisec);


	void UpdateBar(BarData* tick, bool updatestarttm);

	//void UpdateBar(BarData* tick, bool updatestarttm, int f);

	LONGLONG GetBarspan(SYSTEMTIME& ticksys);//not used for tick type

	LONGLONG GetCommodityBarspan(SYSTEMTIME& ticksys);//not used for tick type

	LONGLONG GetStockindexBarspan(SYSTEMTIME& ticksys);//not used for tick type

	int TimeposCommodity(SYSTEMTIME& systm, SYSTEMTIME& startinter1, SYSTEMTIME& endinter1, SYSTEMTIME& startinter2, SYSTEMTIME& endinter2);

	int TimeposStockindex(SYSTEMTIME& systm, SYSTEMTIME& startinter1, SYSTEMTIME& endinter1);



public:
	//bar basic info
	BarSerInfo m_serinfo;//basic bar information including type and count, for example 30 minutes bar, m_barinfo.type = min, m_barinfo.cnt =30. 

	BarData* m_pcur;//point to last bar of series, this bar may not complete(could be control by value of BarData.isend)

	unsigned int m_index;// if m_pcur is avaliable, its value is >=0. ;
	// used to find other avaliable BarDate before m_pcur, for example used to caculate MA(5)
	//unsigned int m_mqindex;
private:
	bool notfirstbar;	

	//bool baccrossday;

	MemMan<BarData>* m_pmemman; // memory management class of BarSeries. used to store Bar Series data. last bar is m_pobarcur. 


	bool bCommidity;

	//unsigned int m_cmldaycnt;

};



#endif